package com.android.slide;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter;

import java.util.List;

/**
 * FileName: ViewPagerAdapter
 * Author: admin
 * Date: 2021/12/1 16:39
 * Description:
 */
public class ViewPagerAdapter extends FragmentPagerAdapter {

    private List<Fragment> fragments = null;
    private List<String> titles = null;

    public ViewPagerAdapter(@NonNull FragmentManager fm, List<Fragment> f, List<String> t) {
        super(fm);
        this.fragments = f;
        this.titles = t;
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Nullable
    @Override
    public CharSequence getPageTitle(int position) {
        return titles.get(position);
    }

    @NonNull
    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }
}